package everydayGrade.t6;

import java.util.*;

/**
 * @Author: Siantar
 * @Date: 2023-10-11-12:33
 * @Description: 1.0
 */
public class T2512 {
    public List<Integer> topStudents(String[] positive_feedback, String[] negative_feedback, String[] report, int[] student_id, int k) {
        Map<String, Integer> map = new HashMap<>();
        for (String s : positive_feedback) {
            map.put(s, 3);
        }
        for (String s : negative_feedback) {
            map.put(s, -1);
        }
        int n=student_id.length;
        int[][] score = new int[n][2];
        for (int i = 0; i < n; i++) {
            score[i][1] = student_id[i];
            for (String s : report[i].split(" ")) {
                score[i][0] += map.getOrDefault(s, 0);
            }
        }
        Arrays.sort(score, (a, b) -> a[0] != b[0] ? b[0] - a[0] : a[1] - b[1]);
        List<Integer> list=new ArrayList<>();
        for (int i = 0; i < k; i++) {
            list.add(score[i][1]);
        }
        return list;

    }
}
